﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentData;
using Framework.Data;

namespace Framework.Core
{
    internal class RuleInfoDataAccess : BaseDataAccess
    {
        internal List<RuleInfo> GetRoleRules(string roleID)
        {
            using (var context = DataHelper.GetBaseDbContext())
            {
                var sql = "SELECT [Rule_Roles].[sRuleID] FROM [Rule_Roles] WHERE [Rule_Roles].[sExpression] LIKE '%'+@RoleID+'%'";
                var roleRules =
                       context.Sql(sql).Parameter("RoleID", roleID).QueryMany<RuleInfo>(delegate(RuleInfo ruleMap, IDataReader ruleReader)
                       {
                           ruleMap.RuleID = ruleReader.GetString("sRuleID");
                           ruleMap.RulePages = new List<RulePage>();
                       });
                return roleRules;
            }
        }
    }
}
